package space.xiaoyuan.middleware.db.router;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component()
@ConfigurationProperties(prefix = "mini-db-router.jdbc.datasource")
public class DBRouterConfig {
    /**
     * 分库数量
     */
    private int dbCount;
    /**
     * 分表数量
     */
    private int tbCount;
    /**
     * 默认分片键
     */
    private String routerKey;
    /**
     * 默认数据源
     */
    private String defaultDatasource;
    /**
     * 数据源map
     */
    private Map<String, DBRouterConfigDetail> datasourceMap;

    public Map<String, DBRouterConfigDetail> getDatasourceMap() {
        return datasourceMap;
    }

    public void setDatasourceMap(Map<String, DBRouterConfigDetail> datasourceMap) {
        this.datasourceMap = datasourceMap;
    }

    public String getDefaultDatasource() {
        return defaultDatasource;
    }

    public void setDefaultDatasource(String defaultDataSource) {
        this.defaultDatasource = defaultDataSource;
    }

    public int getDbCount() {
        return dbCount;
    }

    public void setDbCount(int dbCount) {
        this.dbCount = dbCount;
    }

    public int getTbCount() {
        return tbCount;
    }

    public void setTbCount(int tbCount) {
        this.tbCount = tbCount;
    }

    public String getRouterKey() {
        return routerKey;
    }

    public void setRouterKey(String routerKey) {
        this.routerKey = routerKey;
    }

    public DBRouterConfig() {
    }

    public DBRouterConfig(int dbCount, int tbCount, String routerKey, String defaultDatasource,Map<String,DBRouterConfigDetail> datasourceMap) {
        this.dbCount = dbCount;
        this.tbCount = tbCount;
        this.routerKey = routerKey;
        this.defaultDatasource = defaultDatasource;
        this.datasourceMap = datasourceMap;
    }
}
